/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package object;

import Jama.Matrix;

/**
 *
 * @author dheath
 */
public class CS455Matrix extends Matrix
{
    public CS455Matrix(int n, int m)
    {
        super(n,m);
    }
    
    public CS455Matrix(double[][] array)
    {
        super(array);
    }
    public CS455Matrix(Matrix m)
    {
        super(m.getArrayCopy());
    }
    
    public CS455Matrix times(CS455Matrix m)
    {
        Matrix M = (Matrix)m;
        
        Matrix R = this.times(M);
        
        return new CS455Matrix(R.getArray());
    }
    
    public Point multiplyPoint(Point p)
    {
        CS455Matrix point = new CS455Matrix(4,1);
        point.set(0, 0, p.getX());
        point.set(1,0,p.getY());
        point.set(2,0,p.getZ());
        point.set(3,0,p.getW());
        
        Matrix r = this.times(point);
        
        return new Point((float)r.get(0,0),(float)r.get(1, 0),(float)r.get(2, 0),(float)r.get(3, 0));
    }
    
    public String toString()
    {
        String r = "";
        for(int i = 0; i < this.getRowDimension(); i++)
        {
            r += "|";
            for(int j = 0; j < this.getColumnDimension(); j++)
            {
               r += this.get(i, j); 
            }
            r +="|\n";
        }
        
        return r;
    }
}
